package com.yndsoft.jc.utils;

import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.util.Log;
import com.yndsoft.jc.MyApplication;

public class ExitHelper {
    public Activity nowActivity;

    public ExitHelper(Activity nowActivity) {
        this.nowActivity = nowActivity;
    }

    public void openCloseDialog() {
        Builder builder = new Builder(nowActivity);
        builder.setMessage("您确定要退出吗?");
        builder.setTitle("提示");
        builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // dialog.dismiss();
                // android.os.Process.killProcess(android.os.Process.myPid());
                MyApplication.getInstance().exit();
                Log.i("测试", "......按下了返回键......");
            }
        });
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        builder.create().show();
    }
}
